<template>
  <div class="app-container flex-col minH">
    <div class="topline w100p bgwhite pt20 pb10 radius10 pl10 pr20 justify-between">
      <div>
        <el-input v-model="uid" style="width: 280px" placeholder="搜尋用戶訊息ID..." :prefix-icon="Search" class="search mr10 mb10" />
        <el-input v-model="fromid" style="width: 280px" placeholder="搜尋上級訊息ID..." :prefix-icon="Search" class="search mb10" />

      </div>
      <div class="mb10">
        <el-button class="btn2" @click="getInviteList()">查詢</el-button>
        <el-button class="btn1" @click="reset()">重置</el-button>
      </div>
    </div>
    <div class="mt15 radius10 hidden pb15 flex1 bgwhite  flex-col w100p">
      <div class="flex1 w100p ">
        <el-table :data="tableData" style="width: 100%" cell-class-name="tbcell" header-cell-class-name="hdcell">

          <el-table-column prop="user" label="用戶訊息" min-width="300">
            <template #default="scope">
              <span @click="showUser(scope.row.user.id)">{{ scope.row.user.phone }}(ID:{{ scope.row.user.id }})</span>

            </template>
          </el-table-column>
          <el-table-column prop="fromuser" label="上級訊息" min-width="300">
            <template #default="scope">
              <span @click="showUser(scope.row.fromuser.id)">{{ scope.row.fromuser.phone }}(ID:{{ scope.row.fromuser.id }})</span>

            </template>
          </el-table-column>
          <el-table-column prop="created_at" label="創建時間" min-width="300" sortable />
        </el-table>
      </div>

    </div>

  </div>
</template>

<script setup lang="ts">
import { Search } from '@element-plus/icons-vue'
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router';
import { inviteList } from '@/api/invite.js'
import { inject } from 'vue';
const showUser = inject('showUser');
onMounted(() => {
  getInviteList()
})
const getInviteList = () => {
  inviteList({
    page: currentPage.value,
    per_page: 1000,
    uid: uid.value,
    fromid: fromid.value
  }).then((res) => {
    console.log('系统参数列表', res)
    tableData.value = res.data.data
    total.value = res.data.total
  })
}
const reset = () => {
  uid.value = ''
  fromid.value = ''
  getInviteList()
}
const uid = ref('')
const fromid = ref('')

const tableData = ref([])
const total = ref([])
const currentPage = ref(1)
const router = useRouter()
const toAdd = () => {
  console.log(router)
  router.push({ path: 'addNotice' })
}
const edit = (type) => {
  router.push({ path: 'edit' })
}
</script>

<style lang="scss" scoped>
.search {
  overflow: hidden;
  border-radius: 10px !important;
  // padding: 5px 0px;
}
</style>
<style></style>
